home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Datasheets - TI / tms9918a.txt < prev    next >
Text File  |  2006-10-19  |  24KB  |  627 lines

  1.  
  2.             Texas Instruments TMS9918A VDP
  3.          Complete(?) description including undocumented features
  4.  
  5.             By Sean Young (sean@msxnet.org)
  6.                 Version 0.3 March 1999
  7.  
  8.  
  9. In this document I'll try to give a complete description of the TMS9918A in
  10. software behaviour and display output. I only know the VDP in the MSX system,
  11. in other systems it may have features not described here.
  12.  
  13. You can always find the latest version of this document at:
  14.  
  15.     http://www.msxnet.org/tech/
  16.  
  17. Distribution of this document is unlimited. Any comments are very welcome.
  18.  
  19.  
  20. 1) Overview
  21.  1.1) Colours
  22.  1.2) Registers
  23.  
  24. 2) I/O with the VDP
  25.  2.1) Memory access
  26.  2.2) Register access
  27.  2.3) I/O Ports quirks
  28.  2.4) Interrupts
  29.  
  30. 3) Display modes
  31.  3.1) Mode 0 
  32.  3.2) Mode 1
  33.  3.3) Mode 2
  34.  3.4) Mode 3
  35.  3.5) Undocumented Mode 1 + 2
  36.  3.6) Undocumented Mode 2 + 3
  37.  3.7) Other (Mode 1+3 and Mode 1+2+3)
  38.  
  39. 4) Sprite system
  40.  4.1) Sprite attribute
  41.  4.2) Sprite pattern sizes
  42.  4.3) Illegal sprites and collisions
  43.  
  44. 5) Hardware
  45.  5.1) Pin outs
  46.  
  47. 6) References
  48.  
  49.  
  50. 1) Overview
  51. -----------
  52.  
  53. The VDP is quite simple with 16kB of video memory (or 4kB, but I don't know 
  54. anything about this setup). The display always has a resolution of 256 pixels 
  55. horizontal and 192 pixels vertical. Around this area, there is the border 
  56. colour (back drop) which can be set in the registers. There also is a sprite 
  57. subsystem, with maximum of 4 sprites on a row.
  58.  
  59. There is a PAL version of the chip, and a NTSC version. As far as I know the 
  60. only difference to the system is the interrupt speed: 50Hz for PAL and 60Hz for
  61. NTSC.
  62.  
  63. The TMS9918A was used in quite a few systems: MSX1, Coleco, TI99/4A and 
  64. probably more. I only know it in the MSX1 system.
  65.  
  66.  
  67. 1.1) Colours
  68.  
  69. There are 16 colours. These are static; they can't be changed. Colour 0 is
  70. transparent. I don't know what the exact colours are in colour intensity.
  71. However, the V9938 (MSX2 VDP chip, compatible with the TMS9918A) uses the 
  72. following colours, from 0 to 7:
  73.  
  74.             Green    Red    Blue
  75.  1. Black        0    0    0
  76.  2. Medium Green    6    1    1
  77.  3. Light Green        7    3    3
  78.  4. Dark Blue        1    1    7
  79.  5. Light Blue        3    2    7
  80.  6. Dark Red        1    5    1
  81.  7. Cyan        6    2    7
  82.  8. Medium Red        1    7    1
  83.  9. Light Red        3    7    3
  84. 10. Dark Yellow        6    6    1
  85. 11. Light Yellow    6    6    4
  86. 12. Dark Green        4    1    1
  87. 13. Magenta        2    6    5
  88. 14. Grey        5    5    5
  89. 15. White        7    7    7
  90.  
  91. You can view these colours at:
  92.  
  93.     http://www.msxnet.org/tech/colours.png
  94.  
  95.  
  96. 1.2) Registers
  97.  
  98. The VDP has 8 control registers (0-7) and one status register. 
  99.  
  100. Control Registers:
  101.  
  102. Reg/Bit    7    6    5    4    3    2    1    0
  103. 0    -    -    -    -    -    -    M2    B/W
  104. 1    4/16K    BL    GINT    M1    M3    -    SI    MAG
  105. 2    -    -    -    -    PN13    PN12    PN11    PN10
  106. 3    CT13    CT12    CT11    CT10    CT9    CT8    CT7    CT6
  107. 4    -    -    -    -    -    PG13    PG12    PG11
  108. 5    -    SA13    SA12    SA11    SA10    SA9    SA8    SA7
  109. 6    -    -    -    -    -    SG13    SG12    SG11
  110. 7    TC3    TC2    TC1    TC0    BD3    BD2    BD1    BD0
  111.  
  112. Status Register:
  113.  
  114.     7    6    5    4    3    2    1    0
  115.     INT    5S    C    FS4    FS3    FS2    FS1    FS0
  116.  
  117. The function of the bits is as follows:
  118.  
  119. M1,M2,M3    Select screen mode
  120. B/W        Only black & white output (??)
  121. 4/16K        Selects 16kB RAM if set. No effect in MSX1 system (??)
  122. BL        Blank screen if reset; just backdrop. Sprite system inactive
  123. SI        16x16 sprites if set; 8x8 if reset
  124. MAG        Sprites enlarged if set (sprite pixels are 2x2)
  125. GINT        Generate INTs if set
  126. PN*        Address for pattern name table
  127. CT*        Address for colour table (special meaning in M2)
  128. PG*        Address for pattern generator table (special meaning in M2)
  129. SA*        Address for sprite attribute table
  130. SG*        Address for sprite generator table
  131. TC*        Text colour (foreground)
  132. BD*        Back drop (background). Sets the colour of the border around
  133.         the drawable area. If it is 0, it is black (like colour 1).
  134. FS*        Fifth sprite (first sprite that's not displayed). Only valid
  135.         if 5S is set.
  136. C        Sprite collision detected
  137. 5S        Fifth sprite (not displayed) detected. Value in FS* is valid.
  138. INT        Set at each screen update, used for interrupts.
  139.  
  140. The exact meaning of all these bits should become clear in the remainder of 
  141. this document.
  142.  
  143. The bits marked with `-' are "don't care": set or reset, doesn't make any
  144. difference. However, to maintain downwards compatiblility, you should 
  145. reset these bits.
  146.  
  147. 2) I/O with the VDP
  148. -------------------
  149.  
  150. The VDP has two I/O ports (#0 and #1) which can be read or written. In the MSX
  151. system, they are mapped to port 98h and 99h. The VDP also has an INT output,
  152. which can be used by the CPU to detect screen updates (or vertical blank).
  153.  
  154.  
  155. 2.1) Memory access
  156.  
  157. The 16kB memory can't be accessed directly; only through the I/O ports. To the
  158. contrary to what many (official!) docs say, there is only one read/write 
  159. address where the VDP reads or writes in the 16kB memory. There also is a 
  160. read-ahead buffer, which stores one byte. Memory is "read ahead", so when a
  161. read is requested, it can give the value immediately.
  162.  
  163. This memory address (the r/w address) can be set by writing two bytes to port 
  164. #1. Despite the fact there is only one address, a distinction is made between 
  165. setting it for reading or writing (this because of the read-ahead buffer).
  166.  
  167. The two bytes are formatted as follows:
  168.  
  169.         7    6    5    4    3    2    1    0
  170. Byte #0        A7    A6    A5    A4    A3    A2    A1    A0
  171. Byte #1        0    R/W    A13    A12    A11    A10    A9    A8
  172.  
  173. A13-A0 make up the address. R/W specifies whether you want to read or write
  174. from that address. It should be 0 for reading, 1 for writing.
  175.  
  176. What happens internally in the VDP is interesting. This depends on what you
  177. set the R/W bit to:
  178.  
  179. Write (1):    Simply set the r/w address to the A* value specified.
  180. Read (0):    Read the contents of the A* address from the VRAM and put it
  181.         in the read-ahead buffer. Set the r/w address to A* + 1.
  182.  
  183. Now that the r/w address is set, we can start reading from or writing to it. 
  184. After each access it is increased. By reading port #0 we can read from the 
  185. address, by writing to it we write to the address. What happens internally is:
  186.  
  187. Read:    Return value in read-ahead buffer. Read next value from the r/w 
  188.     address, put it in the read-ahead buffer. Increase the r/w address.
  189. Write:    Write back the value to the r/w address, then increase the r/w address.
  190.     Interestingly, the value written is also stored in the read-ahead 
  191.     buffer.
  192.  
  193. After 3fffh (16kB limit) the r/w address wraps to zero.
  194.  
  195.  
  196. 2.2) Register access
  197.  
  198. The status register can only be read; the control registers can't be read so 
  199. they can only can be written.
  200.  
  201. By reading port #1, you get the value of the status register. After reading
  202. it, bit 7 (INT bit) and bit 5 (C bit) are reset.
  203.  
  204. By writing to port #1, a control register is set. Two bytes must be written
  205. to port #1:
  206.  
  207.         7    6    5    4    3    2    1    0
  208. Byte #0        V7    V6    V5    V4    V3    V2    V1    V0
  209. Byte #1        1    ?    ?    ?    ?    R2    R1    R0
  210.  
  211. The V* bits make up the value written to the register, which is specified
  212. with the R* bits. Bits 6-3 of the second byte are "don't care": it doesn't
  213. matter what value you set them. Officially, they must be 0. It is best to
  214. set them to 0. The downwards TMS9918A compatible V9938 and V9958 have more 
  215. registers and so these bits do have meaning. So, for compatibility, set them 
  216. to 0. Bit 7 must be set, to indicate you want to write to a register; otherwise
  217. you're changing the r/w address.
  218.  
  219.  
  220. 2.3) I/O Ports quirks
  221.  
  222. As you've probably noticed, writes to port #1 must always go in pairs of two
  223. bytes. Suppose you would write one byte to port #1, and let normal programming
  224. continue .. you'd assume that the byte order of any port #1 write is wrong and 
  225. strange things happen. But that isn't true.
  226.  
  227. What happens internally is this. After writing the first byte to port #1, a 
  228. flag is set to indicate that the next byte written to port #1 is the second of 
  229. the pair and completes the register write or r/w address set. This flag is 
  230. reset after that.
  231.  
  232. But this flag is also reset whenever you read port #1, or read or write port
  233. #0. This probably done to prevent an accidental single write to port #1 mess up
  234. the whole programming (which without this setup, would require a hard reset or 
  235. another write to port #1 to return to normal operation).
  236.  
  237. So, in between writing two bytes to port #1, never access any other port of the
  238. VDP. This is why interrupts must be disabled during writing to port #1: the 
  239. interrupt service routine most likely accesses the VDP (status register read 
  240. for example) and that will mess it up.
  241.  
  242.  
  243. 2.4) Interrupts
  244.  
  245. The VDP can generate interrupts for the CPU. It works as follows: at the end
  246. of the last line of the screen (after vertical line 192, last of the drawable 
  247. screen; at the begining of the bottom part of the backdrop) bit 7 of status 
  248. register is set. 
  249.  
  250. If bit 7 of the status register is set (INT), and bit 5 of control register #1
  251. is set (GINT), the INT output line is low (requesting an interrupt), otherwise
  252. it is high (not requesting an interrupt).
  253.  
  254. So if bit 5 of control register #1 is reset, interrupts are never requested.
  255.  
  256. After the status register is read, bit 7 is reset. The INT line goes high
  257. again, so it isn't requesting an interrupt anymore. That's why this register
  258. must always be read in an interrupt routine: otherwise the INT is remains low
  259. and the interrupt service routine is called again and again.
  260.  
  261. Another interesting fact is this: if bit 5 of control register #1 is reset,
  262. and you set it, and bit 7 of the status register was set, the INT line goes
  263. low immediately and an interrupt is requested. This is important for emulators
  264. too: if this isn't emulated properly, the MSX game Track & Field 1 and 2 slows
  265. down considerbly.
  266.  
  267.  
  268. 3) Screen modes
  269. ---------------
  270.  
  271. There are 4 official screen modes but 3 mode bits (8 possibilities). The
  272. modes define how the screen is built up. In some modes, the sprite subsystem
  273. is active which is described in section 4).
  274.  
  275. All screen modes are character based.
  276.  
  277. Screen mode x simply means the respective Mx bits are set. Mode 0 indicates
  278. none of the M* bits are set.
  279.  
  280.  
  281. 3.1) Mode 0 
  282.  
  283. This screen mode is known as SCREEN 1 in MSX BASIC, and GRAPHIC 1 in the
  284. V9938 Technical Data Book.
  285.  
  286. Like most screen modes, it has width 32 characters and 24 characters vertical.
  287. The sprite subsystem is active.
  288.  
  289. Since the size is 32 x 24, the Pattern Name Table (PN) has 32 x 24 = 768 
  290. elements, which are bytes refering to the Pattern Generator Table (PG) and 
  291. Colour Table (CT). 
  292.  
  293. The first character is the top-left one, the second the one to the right of
  294. it. Character no. 32 the first character of the second row.
  295.  
  296. Each character is 8 x 8. The character number refers to an character pattern in
  297. the PG, which has 256 characters patterns. Each pattern is 8 bytes, so the
  298. entire PG is 256 x 8 = 2048 bytes. Each byte is a pixel line of the character 
  299. (top first). If a bit is set, the foreground colour in the CT is shown, 
  300. otherwise the background colour in the CT.
  301.  
  302. The CT sets the colour of the character. Each byte in the CT sets the colour 
  303. of 8 complete characters, so the CT is 32 bytes. The high four bits set the
  304. foreground colour, the low the background colour. If either of these is 0,
  305. it is transparent and the colour of the backdrop (BD) is used. To calculate
  306. the element in the CT, divide the character number in PN by 8.
  307.  
  308. The TC in control register #7 is not used in this mode.
  309.  
  310.  
  311. 3.2) Mode 1
  312.  
  313. This mode is known as SCREEN 0 in MSX BASIC, and as TEXT 1 in the V9938 
  314. Technical Data Book.
  315.  
  316. In this mode, the screen has width 40 characters and 24 characters vertical. 
  317. Only two colours are used, TC and BD from control register #7. Since the 
  318. characters are 6 pixels wide, the width is 40 x 6 = 240. There is a 8 pixels
  319. border at the left and right side of the screen (with the colour of the back 
  320. drop). The sprite subsystem is inactive.
  321.  
  322. Since the size is 40 x 24, the Pattern Name Table (PN) has 40 x 24 = 960 
  323. elements, which are bytes refering to the Pattern Generator Table (PG). The
  324. Colour Table (CT) is not used.
  325.  
  326. The first character is the top-left one, the second the one to the right of
  327. it. Character no. 40 the first character of the second row.
  328.  
  329. Each character is 6 x 8 pixels. The character number refers to a character 
  330. pattern in the PG, which has 256 characters patterns. Each pattern is 8 bytes, 
  331. so the entire PG is 256 x 8 = 2048 bytes. Each byte is a pixel line of the 
  332. character (top first). If a bit is set, the TC in control register #7 is shown,
  333. otherwise BD in the same register. The two highest bits of each byte in the PG
  334. are ignored.
  335.  
  336.  
  337. 3.3) Mode 2
  338.  
  339. This mode is known as SCREEN 2 in MSX BASIC, and as GRAPHIC 2 in the V9938 
  340. Data Book. It is the most complex and has the most possibilities of all the 
  341. modes of the TMS9918A.
  342.  
  343. Like most screen modes, it has width 32 characters and 24 characters vertical.
  344. The sprite subsystem is active.
  345.  
  346. Since the size is 32 x 24, the Pattern Name Table (PN) has 32 x 24 = 768 
  347. elements, which are bytes refering to the Pattern Generator Table (PG) and 
  348. Colour Table (CT). 
  349.  
  350. The first character is the top-left one, the second the one to the right of
  351. it. Character no. 32 the first character of the second row. There are three
  352. colour and three pattern tables. The character number is as follows:
  353.  
  354. The first 8 rows: byte from PN + 000h
  355. The middle 8 rows: byte from PN + 100h
  356. The bottom 8 rows: byte from PN + 200h
  357.  
  358. Each character is 8 x 8. The character number refers to an character pattern in
  359. the PG, which has 768 characters patterns (three seperate tables). For the first
  360. 8 rows of the screen, the first 256 entries are used. For the second 8 rows,
  361. the second 256 patterns, and for the last 8 rows the third 256 patterns 
  362. (depending on the value of control register #4, see below). So the entire PG is
  363. 3 x 256 x 8 = 6144 bytes. Each byte is a pixel line of the character (top 
  364. first). If a bit is set, the foreground colour in the CT is used, otherwise 
  365. the background colour in the CT.
  366.  
  367. Control register #4 which sets the PG address of the PG has a different 
  368. function in mode 2. Only bit 2, PG13, sets the address of the PG (so it's either
  369. address 0 or 2000h). Bits 0 and 1 are an AND mask over the character number. 
  370. The character number is 0 - 767 (2FFh) and these two bits are ANDed over the 
  371. two highest bits of this value (2FFh is 10 bits, so over bit 8 and 9). So in 
  372. effect, if bit 0 of control register #4 is set, the second array of 256 
  373. patterns in the PG is used for the middle 8 rows of characters, otherwise the 
  374. first 256 patterns. If bit 1 is set, the third array of patterns is used in 
  375. the PG, otherwise the first.
  376.  
  377. The relation PN -> CT is the same as PN -> GT. Each byte in the CT sets the
  378. colour of one pixel line of a character.  The high four bits set the foreground 
  379. colour, the low the background colour. If either of these is 0, it is 
  380. transparent and the colour of the backdrop (BD) is used. 
  381.  
  382. Also control register #3 has a different meaning. Only bit 7 (CT13) sets the CT
  383. address. Somewhat like control register #4 for the PG, bits 6 - 0 are an AND
  384. mask over the top 7 bits of the character number.
  385.  
  386. The TC in control register #7 is not used in this mode.
  387.  
  388.  
  389. 3.4) Mode 3
  390.  
  391. This mode is known as SCREEN 3 in MSX-BASIC, and as MULTICOLOR in the V9938
  392. Technical Data Book. In this mode, each `unit' on the screen is 4 x 4 pixels. 
  393. In these units all the pixels have the same colour. Unlike all the other modes
  394. there is no colour spill (each pixel can have any colour). The sprite subsystem 
  395. is active.
  396.  
  397. The characters are 8 x 8 pixels. There are 32 x 24 characters on the screen,
  398. so the pattern name table (PN) has 768 elements (bytes) which refer to a 
  399. pattern in the pattern generator table (PG). Only two bytes of the 8 bytes in
  400. the pattern are used. Which two bytes depends on the vertical row (0 - 23).
  401. The address in the PG can be calculated as follows:
  402.  
  403.     PG + (byte in PN) x 8 + (row AND 3) x 2
  404.  
  405. Each character is 4 units. Each byte sets the color of two blocks of 4 x 4 
  406. pixels. The lower four bits set the colour of the left block, the highest four 
  407. bits set the colour of the right block. If either is 0, the block is transparent
  408. and the backdrop (BD) is visible. 
  409.  
  410. The TC in control register #7 is not used in this mode, neither is the colour
  411. table (CT).
  412.  
  413.  
  414. 3.5) Undocumented Mode 1 + 2
  415.  
  416. This mode is very much like Mode 1; the difference is that there can be three
  417. different pattern tables, and control register #4 has a different meaning.
  418.  
  419. The pattern table now has 3 x 256 patterns; the screen is divided in three
  420. parts (the top 8 character rows, the middle 8, the bottom 8). Each part can
  421. use a different part of the pattern generator table (the first 256, the second 
  422. 256, the last 256). The top part always uses the first 256 patterns in the PG.
  423.  
  424. Control register #4:
  425.  bit 7 - 3 : ignored
  426.  bit 2     : PG13; if set, PG = 2000h otherwise 0
  427.  bit 1        : if set, the last 8 rows use the 3rd pattern table otherwise 1st.
  428.  bit 0     : if set, the middle 8 rows use the 2nd pattern table otherwise 1st.
  429.  
  430. This undocumented mode is not available in the V9938 as far as I know.
  431.  
  432.  
  433. 3.6) Undocumented Mode 2 + 3
  434.  
  435. This mode is very much like Mode 3; it differs in the same way that 
  436. undocumented mode 1 + 2 differs from mode 1. See section above for details.
  437.  
  438.  
  439. 3.7) Other (Mode 1+3 and Mode 1+2+3)
  440.  
  441. There are two undocumented modes left: 1+3 and 1+2+3. Something weird happens
  442. in both modes: no longer do the tables have any influence on how the screen looks 
  443. like. The screen simply shows 40 vertical lines of text colour (TC). By the 
  444. looks of it, it's 4 pixels TC, 2 pixels BD. Like in mode 1, there is a 8 pixel
  445. border with colour backdrop (BD) at the left and right of the screen.
  446.  
  447. The sprite subsystem is inactive.
  448.  
  449.  
  450. 4) Sprite system
  451. ----------------
  452.  
  453. In all modes except when M1 is set or BL is reset, the sprite subsystem is 
  454. active. Sprites can be either 8 x 8 pixels, or 16 x 16; also these pixels can 
  455. be enlarged (twice the size; "zoomed").
  456.  
  457.  
  458. 4.1) Sprite attribute table
  459.  
  460. 32 different sprites can be display at the same time on the same screen, with
  461. the exception that no more than 4 four sprites can be displayed on one 
  462. horizontal pixel line. The location and colour of the sprites is specified in 
  463. the sprite attribute table (SA). For each of the 32 sprites, there are four 
  464. bytes.
  465.  
  466. SA ->    0    Y sprite 0
  467.     1    X sprite 0
  468.     2    sprite pattern 0
  469.     3    colour sprite 0 + EC
  470.     4    Y sprite 1
  471.     5    X sprite 1
  472.     6    sprite pattern 1
  473.     7    colour sprite 1 + EC
  474.     .
  475.     .
  476.  
  477. The values have special meanings. If the Y coordinate is 0, it's displayed on
  478. the second pixel line from the top. With value 255 it's exactly on the the top
  479. line, and with coordinate 254 the top line isn't visible any more, with 253 to
  480. two top lines aren't visible any more, etc.
  481.  
  482. If Y is 208, that sprite and all following sprites in the table are not 
  483. displayed.
  484.  
  485. The X coordinate is simply, as you would expect, the X coordinate from 0 to 
  486. 255. If bit 7 of the ``colour sprite'' is set (Early Clock -- EC), the sprite
  487. is moved 32 pixels to the left; in this way it's possible to partially display
  488. the sprite at the left side.
  489.  
  490. The lower 4 bits of ``colour sprite'' define the colour. Bit 7 is the EC.
  491. Bits 6 - 4 should be zero officially, but they are ignored. If the colour is 
  492. 0, the sprite is transparent (not visible).
  493.  
  494.  
  495. 4.2) Sprite generator & sizes
  496.  
  497. These options are in the control register #1. If bit 0 (MAG) is set, the 
  498. sprites are enlarged. If bit 1 (SI) is set, the sprites are 16 x 16 in size,
  499. otherwise 8 x 8.
  500.  
  501. The sprite pattern defines which pattern to use. In the case of 8 x 8 sprites,
  502. there are 8 bytes for the sprite pattern, and there are 256 patterns in the
  503. sprite generator table (SG). So simply multiply the sprite pattern by 8 to 
  504. get the address in the SG. Each of these bytes set the colour of the pixels
  505. of the sprite. If a bit is set, the pixel has the colour of the ``colour
  506. sprite'' -- unless it is 0, in which case it is transparent.
  507.  
  508. In the case of 16 x 16, it is slightly more complex. The SG is still 256 x 8
  509. bytes, and each pattern is 32 bytes now. To calculate the address in the
  510. SG: ((pattern number) AND 252) x 8. The first 16 bytes set the colour of the
  511. left 8 pixels of the sprite, the next 16 bytes set the colour of the right
  512. 16 pixels of the sprite. If it is 0, it is transparent.
  513.  
  514. If bit 0 of control register 1 (MAG) is set, the sprites are enlarged. The
  515. starting coordinates are the same, but every pixel of the sprite is 2 x 2 
  516. real pixels. 
  517.  
  518.  
  519. 4.3) Illegal sprites & sprite collision
  520.  
  521. On each horizontal pixel line, only 4 sprites are allowed. Any more than that 
  522. are not displayed. These sprites that aren't displayed are known as ``illegal
  523. sprites''. The first sprite illegal sprite that is detected is put in the
  524. status register. Bit 6 (5S) is set, to show an illegal sprite is detected. The
  525. sprite number (SA element number) is stored in the FS* bits. Note that even 
  526. transparent (colour 0) sprites count for illegal sprites, and sprites that 
  527. aren't displayed because they're of the left or right side of the screen.
  528.  
  529. If no illegal sprite was found, 5S won't be set and FS* contains the highest
  530. sprite number in the SA, either the last (31) or the first with Y coordinate
  531. 208 (if it exists). Note that isn't fully checked (but probably not really
  532. important).
  533.  
  534. Remember the screen is built line by line from top to bottom; the first illegal
  535. sprite is on the highest pixel line with an illegal sprite.
  536.  
  537. If anywhere on the screen two or more sprites overlap, the C bit of the status
  538. register is set. The colour of the sprite is not important (can even be 0), the 
  539. pattern is. If a sprite line is not displayed because it is illegal, it does 
  540. not count for sprite collision. The C bit of the status register is reset
  541. after the register is read.
  542.  
  543.  
  544. 5) Hardware
  545. -----------
  546.  
  547. 5.1) Pin outs
  548.  
  549.             TMS9918A
  550.  
  551.         +--------------+
  552.        _RAS | 1        40 | XLAT2 
  553.        _CAS | 2        39 | XLAT1
  554.         AD7 | 3        38 | CPUCLK
  555.         AD6 | 4        37 | GROMCLK
  556.         AD5 | 5        36 | COMVID
  557.         AD4 | 6        35 | EXTVDP
  558.         AD3 | 7        34 | _RESET / SYNC
  559.         AD2    | 8        33 | Vcc
  560.         AD1 | 9        32 | RD0
  561.         AD0 | 10        31 | RD1
  562.        R/_W | 11        30 | RD2
  563.         Vss | 12        29 | RD3
  564.        MODE | 13        28 | RD4
  565.        _CSW | 14        27 | RD5
  566.        _CSR | 15        26 | RD6
  567.        _INT | 16        25 | RD7
  568.         CD7 | 17        24 | CD0
  569.         CD6 | 18        23 | CD1
  570.         CD5 | 19        22 | CD2
  571.         CD4    | 20        21 | CD3
  572.         +--------------+
  573.  
  574.  
  575.             TMS9928A
  576.  
  577.         +--------------+
  578.        _RAS | 1        40 | XLAT2 
  579.        _CAS | 2        39 | XLAT1
  580.         AD7 | 3        38 | R-Y
  581.         AD6 | 4        37 | GROMCLK
  582.         AD5 | 5        36 | Y
  583.         AD4 | 6        35 | B-Y
  584.         AD3 | 7        34 | _RESET / SYNC
  585.         AD2    | 8        33 | Vcc
  586.         AD1 | 9        32 | RD0
  587.         AD0 | 10        31 | RD1
  588.        R/_W | 11        30 | RD2
  589.         Vss | 12        29 | RD3
  590.        MODE | 13        28 | RD4
  591.        _CSW | 14        27 | RD5
  592.        _CSR | 15        26 | RD6
  593.        _INT | 16        25 | RD7
  594.         CD7 | 17        24 | CD0
  595.         CD6 | 18        23 | CD1
  596.         CD5 | 19        22 | CD2
  597.         CD4    | 20        21 | CD3
  598.         +--------------+
  599.  
  600.  
  601.  
  602. 6) References
  603. -------------
  604.  
  605. Unfortunately, I don't have any really good TMS9918A documentation, but using
  606. information from various sources I was able to put this together. 
  607.  
  608. MSX Handboek voor gevorderden
  609.     A Dutch MSX1 technical manual. It's full of mistakes but very complete.
  610.  
  611. V9938 MSX-Video Technical Data Book
  612.     The be-all, end-all guide to the MSX2 VDP; some things are true for the
  613.     TMS9918A VDP too.
  614.  
  615. http://www.msxnet.org/tech/tmsposting.txt
  616.     A posting by Paul Urbanus (urb@onramp.net) in comp.emulators.misc.
  617.     Very interesting stuff about timings and the one r/w address.
  618.  
  619. http://home.swipnet.se/~w-16418/tech_vdp.htm
  620.     This is an expanded version of my original tms9918a document. It's more 
  621.     complete than my old version, but this document should be better. :-)
  622.  
  623. http://mess.emuverse.com/
  624.     The MESS emulator, includes a TMS9928A emulator written by me, all 
  625.     undocumented features described here are emulated.
  626.  
  627.